package model.dao.registerOrder;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import log.MyLogger;
import model.service.SoStatusType;


public class SoStatusTypeDAOImpl {

	String sql = "" ;
	db.dbconnection dbconnection ;
	Connection myConnection ;
	Statement st ;
	
	public List<SoStatusType> getAllSoStatusTypes() {
		List<SoStatusType> types = new ArrayList<SoStatusType>();
		try {
			myConnection = dbconnection.getConnection();
			Statement s = myConnection.createStatement();
			String sql = "select * from so_status_type";
			ResultSet resultSet = s.executeQuery(sql);
			while(resultSet.next()){
				SoStatusType soStatusType = new SoStatusType();
				soStatusType.setTypeName(resultSet.getString("type_name"));
				soStatusType.setSoStatusType(resultSet.getInt("so_status_type"));
				types.add(soStatusType);
			}
			this.dbconnection.close();
		} catch (Exception e) {
//			MyLogger.Log("SoStatusTypeDAOImpl.getAllSoStatusTypes()",e.getMessage());
		}
		return types;
	}

	public SoStatusType getStatusTypeById(int id) {
		SoStatusType type = new SoStatusType();
		try {
			dbconnection = new db.dbconnection();
			myConnection = dbconnection.getConnection();
			Statement s = myConnection.createStatement();
			String sql = "select * from so_status_type where so_status_type="+id;
			ResultSet resultSet = s.executeQuery(sql);
			while(resultSet.next()){
				
				type.setTypeName(resultSet.getString("type_name"));
				type.setSoStatusType(resultSet.getInt("so_status_type"));
				
			}
			this.dbconnection.close();
		} catch (Exception e) {
//			MyLogger.Log("SoStatusTypeDAOImpl.getStatusTypeById()",e.getMessage());
		}
		return type;
	}

}
